package com.example.firstapp;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.util.Log;

import org.jsoup.Jsoup;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;
import org.w3c.dom.Document;

import java.io.IOException;

public class MainActivity extends AppCompatActivity {
    private static final String TAG="wwwww";
    @Override
    protected void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        try {
            Document doc= (Document) Jsoup.connect("https://www.baidu.com").get();
//            Log.i(TAG,"run:title=" + doc.title());
            Elements as= (Elements) doc.getElementsByTagName("a");
            for(Element a:as){
                Log.i(TAG,"run:a=" + a);
            }

            Elements tables= (Elements) doc.getElementsByTagName("table");
            Element table=tables.get(0);
            Log.i(TAG,"run: table="+table.text());

            Elements trs= (Elements) doc.getElementsByTagName("tr");
            for (Element tr:trs){
                Log.i(TAG,"run: tr=" + tr);
            }
            Elements tds= (Elements) doc.getElementsByTagName("td");
            for (Element td:tds){
                Log.i(TAG,"run: td=" + td);
            }

        } catch (IOException e) {
            e.printStackTrace();
        }
   }
}